//
//  AppInfoViewController.m
//  LimitFree
//
//  Created by qianfeng on 15/8/28.
//  Copyright (c) 2015年 Hailong.wang. All rights reserved.
//

#import "AppInfoViewController.h"
#import "AppModel.h"
#import "PhotosModel.h"
#import "ThirdCell.h"
#import "FristCell.h"
#import "SecondCell.h"
@interface AppInfoViewController ()<UITableViewDataSource,UITableViewDelegate>{
    NSString* _appID;
    //数据源
    AppModel* _inforData;
    
    UITableView* _tableView;
}

@end

@implementation AppInfoViewController
-(id)initWithApplicationID:(NSString*)applicationID{
    self=[super init];
    if (self) {
        _appID=[applicationID copy];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"应用详情";
    // Do any additional setup after loading the view.
}
-(void)initData{
    [self getNetData];
}
-(void)getNetData{
    NSString* urlString=[NSString stringWithFormat:@"%@%@",kDetailUrl,_appID];
    [NetRequestManager GET:urlString parame:@{@"currency":@"rmb"} succes:^(AFHTTPRequestOperation *operation, id responseObject) {
       // NSLog(@"%@ %@",responseObject,operation.request.URL);
        _inforData=[[AppModel alloc]initWithData:responseObject error:nil];
        //NSLog(@"%@",_inforData);
    } failed:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}
-(void)createView{
    _tableView=[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    _tableView.delegate=self;
    _tableView.dataSource=self;
    [self.view addSubview:_tableView];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - UItableViewDelegate& UItableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return section==0?2:1;
    //return 1;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section==0) {
        
    
    static NSString* identifier=@"Identifier";
    UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
    }
    return cell;
    }else{
        static NSString* specialCell=@"specailCell";
        ThirdCell* cell=[tableView dequeueReusableCellWithIdentifier:specialCell];
        if (!cell) {
            cell=[[[NSBundle mainBundle]loadNibNamed:@"ThirdCell" owner:self options:nil]lastObject];
        }
        return cell;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    //return 100;
    if (indexPath.section==0) {
        return 100.f;
    }else{
        return 80.f;
    }
}
@end
